<!DOCTYPE html><html lang="zh-CN"><head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>&#x81EA;&#x5B9A;&#x4E49; | Moment.js &#x6587;&#x6863;</title>
  <link rel="stylesheet" href="static/css/style.css">
  <link rel="shortcut icon" href="http://momentjs.cn/static/img/moment-favicon.png">
  <link rel="stylesheet" href="static/css/atom-one-light.min.css">
</head>
<body class="is-moment">
  <div class="hero hero-oneline">
    <div class="hero-centered">
      <h1>&#x81EA;&#x5B9A;&#x4E49;</h1>
    </div>
  </div>
  <div id="api-section-__FILENAME__">
    <div id="content" class="clearfix">
  
      <div id="column1" data-id="__ID__" class="interior">
        <header>
          <!-- <h1>自定义</h1> -->
          <div id="gtoc">
            <ul>
              <!-- <li>v</li> -->
              <li>
                <a href="index.html#/customization/" name="toc">&#x8FD4;&#x56DE;&#x4E0A;&#x5C42;&#x6587;&#x6863;</a>
              </li>
              <li style="border: none;">
                <a href="javascript:window.open('https://github.com/momentjscn/moment-docs-cn/edit/master/moment/07-customization/00-intro.md');" rel="nofollow" target="_blank">&#x63D0;&#x4EA4;&#x4FEE;&#x6539;</a>
              </li>
              <!-- <li>
                <a href="/search__SEARCH_PARAM__" name="toc">搜索</a>
              </li> -->
            </ul>
          </div>
          <hr>
        </header>

        <div id="biz_item"></div>
  
        <div id="apicontent">
          <div id="content_left">
<p>Moment.js &#x975E;&#x5E38;&#x5BB9;&#x6613;&#x81EA;&#x5B9A;&#x4E49;&#x3002;
&#x901A;&#x5E38;&#xFF0C;&#x5E94;&#x8BE5;&#x4F7F;&#x7528;&#x81EA;&#x5B9A;&#x4E49;&#x521B;&#x5EFA;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x3002;</p>
<pre><code class="language-javascript">moment.locale(&apos;en-my-settings&apos;, {
    // &#x81EA;&#x5B9A;&#x4E49;
});
</code></pre>
<p>&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x4F20;&#x5165; <code>null</code> &#x4F5C;&#x4E3A;&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;&#x6765;&#x79FB;&#x9664;&#x5148;&#x524D;&#x5B9A;&#x4E49;&#x7684;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x3002;
&#x5220;&#x9664;&#x7684;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x5C06;&#x4E0D;&#x518D;&#x53EF;&#x7528;&#x3002;</p>
<pre><code class="language-javascript">moment.locale(&apos;fr&apos;); // &apos;fr&apos;
moment.locale(&apos;en&apos;); // &apos;en&apos;
moment.locale(&apos;fr&apos;, null);
moment.locale(&apos;fr&apos;); // &apos;en&apos;
</code></pre>
<p>&#x4ECE; <strong>2.12.0</strong> &#x5F00;&#x59CB;&#xFF0C;&#x53EF;&#x4EE5;&#x521B;&#x5EFA;&#x4ECE;&#x7236;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x7EE7;&#x627F;&#x7684;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x3002;</p>
<pre><code class="language-javascript">moment.defineLocale(&apos;en-foo&apos;, {
  parentLocale: &apos;en&apos;,
  /* */
});
</code></pre>
<p>&#x5728;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x4E2D;&#x672A;&#x6307;&#x5B9A;&#x7684;&#x5C5E;&#x6027;&#x5C06;&#x4F1A;&#x4ECE;&#x7236;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x4E2D;&#x7EE7;&#x627F;&#x3002;</p>
<p>&#x4ECE; <strong>2.16.0</strong> &#x7248;&#x672C;&#x5F00;&#x59CB;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x5C1A;&#x672A;&#x5B9A;&#x4E49;&#x6216;&#x52A0;&#x8F7D;&#x7684;&#x7236;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x6765;&#x5B9A;&#x4E49;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x3002;</p>
<pre><code class="language-javascript">moment.defineLocale(&apos;fakeLocale&apos;, {parentLocale:&apos;xyz&apos;})
</code></pre>
<p>&#x4ECE; <strong>2.21.0</strong> &#x5F00;&#x59CB;&#xFF0C;&#x5F53;&#x5C1D;&#x8BD5;&#x4F7F;&#x7528;&#x65B0;&#x5B9A;&#x4E49;&#x7684;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x521B;&#x5EFA; moment &#x65F6;&#xFF0C;&#x5982;&#x679C;&#x5B58;&#x5728;&#x7236;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#xFF0C;&#x5219; moment &#x5C06;&#x4F1A;&#x5C1D;&#x8BD5;&#x5EF6;&#x8FDF;&#x52A0;&#x8F7D;&#x5B83;&#x3002;
&#x5F53;&#x5931;&#x8D25;&#x65F6;&#xFF0C;&#x5B83;&#x4F1A;&#x9ED8;&#x8BA4;&#x5C06;&#x7236;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x8BBE;&#x7F6E;&#x4E3A;&#x5168;&#x5C40;&#x7684;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x3002;</p>
<p>&#x4ECE; <strong>2.12.0</strong> &#x5F00;&#x59CB;&#xFF0C;&#x8FD8;&#x53EF;&#x4EE5;&#x66F4;&#x65B0;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x7684;&#x5C5E;&#x6027;&#x3002;</p>
<pre><code class="language-javascript">moment.updateLocale(&apos;en&apos;, {
  /**/
});
</code></pre>
<p>&#x6307;&#x5B9A;&#x7684;&#x4EFB;&#x4F55;&#x5C5E;&#x6027;&#x5C06;&#x4F1A;&#x88AB;&#x66F4;&#x65B0;&#xFF0C;&#x800C;&#x5176;&#x4ED6;&#x5C5E;&#x6027;&#x5C06;&#x4F1A;&#x4FDD;&#x6301;&#x4E0D;&#x53D8;&#x3002;
&#x6B64;&#x51FD;&#x6570;&#x4E0D;&#x4F1A;&#x5F71;&#x54CD;&#x5DF2;&#x7ECF;&#x5B58;&#x5728;&#x7684; moment&#x3002;</p>
<p>&#x8981;&#x8FD8;&#x539F;&#x66F4;&#x65B0;&#xFF0C;&#x5219;&#x4F7F;&#x7528;&#xFF1A;</p>
<pre><code class="language-javascript">moment.updateLocale(&apos;en&apos;, null);
</code></pre>
<p>&#x4F7F;&#x7528; <code>moment.locale()</code> &#x66F4;&#x6539;&#x73B0;&#x6709;&#x7684;&#x8BED;&#x8A00;&#x73AF;&#x5883;&#x5DF2;&#x5E9F;&#x5F03;&#x4E8E; <strong>2.12.0</strong>&#x3002;
&#x6539;&#x7528; <code>moment.updateLocale()</code>&#x3002;</p>
					</div>
          <div id="content_right">
<p>Moment.js is very easy to customize. In general, you should create a locale setting with your customizations.</p>
<pre><code class="language-javascript">moment.locale(&apos;en-my-settings&apos;, {
    // customizations.
});
</code></pre>
<p>You can remove a previously defined locale by passing <code>null</code> as the second argument.
The deleted locale will no longer be available for use.</p>
<pre><code class="language-javascript">moment.locale(&apos;fr&apos;); // &apos;fr&apos;
moment.locale(&apos;en&apos;); // &apos;en&apos;
moment.locale(&apos;fr&apos;, null);
moment.locale(&apos;fr&apos;); // &apos;en&apos;
</code></pre>
<p>As of <strong>2.12.0</strong> it is possible to create a locale that inherits from a parent locale.</p>
<pre><code class="language-javascript">moment.defineLocale(&apos;en-foo&apos;, {
  parentLocale: &apos;en&apos;,
  /* */
});
</code></pre>
<p>Properties that are not specified in the locale will be inherited from the parent locale.</p>
<p>As of <strong>2.16.0</strong> it is possible to define a locale with a parent that hasn&apos;t itself been defined or loaded.</p>
<pre><code class="language-javascript">moment.defineLocale(&apos;fakeLocale&apos;, {parentLocale:&apos;xyz&apos;})
</code></pre>
<p>As of <strong>2.21.0</strong> when attempting to create a moment with the newly defined locale, moment will attempt to lazy load the parent if it exists. Failing that it will default the parent to the global locale.</p>
<p>As of <strong>2.12.0</strong> it is also possible to update a locale&apos;s properties.</p>
<pre><code class="language-javascript">moment.updateLocale(&apos;en&apos;, {
  /**/
});
</code></pre>
<p>Any properties specified will be updated, while others will remain the same. This function does not affect moments that already exist.</p>
<p>To revert an update use:</p>
<pre><code class="language-javascript">moment.updateLocale(&apos;en&apos;, null);
</code></pre>
<p><strong>2.12.0</strong> deprecated using <code>moment.locale()</code> to change an existing locale. Use <code>moment.updateLocale()</code> instead.</p>
					</div>
          <div></div>
        </div>
      </div>
    </div>
  </div>
  
  <script src="static/js/highlight.min.js"></script>
  <script src="static/js/javascript.min.js"></script>
  <script>hljs.initHighlightingOnLoad();</script>
  <script>var _hmt = _hmt || []; (function () { var hm = document.createElement("script"); hm.src = "//hm.baidu.com/hm.js?7a7f78c805fbacc7e075d34f153031aa"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })();</script>

  <style>
    .hero-centered {
      margin: 0;
          margin-left: 10px;
    }
#gtoc ul {
  list-style: none;
  margin-left: 0;
  line-height: 1.5rem;
  padding: 0;
}
#gtoc>ul>li {
  display: inline;
  border-right: 1px solid #000;
  margin-right: .4rem;
  padding-right: .4rem;
}
#gtoc>ul>li>a {
  color: #61b2a7;
}
#content_left {
  width: 49%;float: left;border-right: 1px solid #eee;    padding-right: 2%;
}
#content_right {
float: left;width: 48%;margin-left: 3%;
}
#column1 {
  padding: 0 2rem;
}
  </style>


</body></html>